package com.hotel.reservation.service.impl;

import com.hotel.reservation.dao.UserDao;
import com.hotel.reservation.po.Message;
import com.hotel.reservation.po.Reserve;
import com.hotel.reservation.po.User;
import com.hotel.reservation.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public List<User> login(User user) {
        System.out.println(userDao.login(user).size()+"inUserService");
        return userDao.login(user);
    }

    @Override
    public int register(User user) {
        if (userDao.findOneUserByTel(user.getUserTel()).size() > 0) {
            return -1;
        }
        return userDao.addUser(user);
    }

    @Override
    public List<User> findOneUser(String tel) {
        return userDao.findOneUserByTel(tel);
    }

    @Override
    public List<User> findOneUserById(int id) {
        return userDao.findOneUserById(id);
    }

    @Override
    public List<Message> findUserMessage(int id) {

        return userDao.selectUserMessage(id);
    }

    @Override
    public List<Reserve> findUserReserve(int id) {
        return userDao.selectUserReserve(id);
    }

    @Override
    public List<User> selectAllUserByPage(Map map) {
        return userDao.selectAllUserByPage(map);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUserByTel(user);
    }

    @Override
    public int deleteUser(String tel) {
        return userDao.deleteUser(tel);
    }
}
